package com.siwen.service.impl;

import com.siwen.common.ErrorCode;
import com.siwen.exception.UserException;
import com.siwen.mapper.ChildMapper;
import com.siwen.service.ChildService;
import com.siwen.pojo.ChildTbl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ChildServiceImpl implements ChildService {

    @Resource
    private ChildMapper childMapper;

    @Override
    public List<ChildTbl> getChildInfo() {
        return childMapper.getChildInfo();
    }

    @Override
    public ChildTbl ChildLogin(String username, String password) throws UserException {
        if("".equals(username)&& "".equals(password)){
            throw new UserException(ErrorCode.NULL_VALUE);
        }
        ChildTbl childTbl=childMapper.ChildLogin(username,password);
        if(childTbl==null){
            throw  new UserException(ErrorCode.ACCESS_DENIED);
        }
        return childTbl;
    }

    @Override
    public int insertChild(ChildTbl child) {
        return childMapper.insertChild(child);

    }
}
